﻿using Grpc.Net.Client.Balancer;
using Microsoft.Extensions.Logging;
using Nacos.V2;

namespace XYS.Service.Core.Startup.gRPC
{
    /// <summary>
    /// 
    /// </summary>
    public class NacosResolverFactory : ResolverFactory
    {
        private readonly INacosNamingService _nacosNamingService;

        /// <summary>
        /// 
        /// </summary>
        /// <param name="nacosNamingService"></param>
        public NacosResolverFactory(INacosNamingService nacosNamingService)
        {
            _nacosNamingService = nacosNamingService;
        }

        /// <summary>
        /// 
        /// </summary>
        public override string Name => "nacos";

        /// <summary>
        /// 
        /// </summary>
        /// <param name="options"></param>
        /// <returns></returns>
        public override Resolver Create(ResolverOptions options)
        {
            // 创建 NacosResolver，并传入 Nacos 客户端实例
            return new NacosResolver(options.Address, _nacosNamingService, options.LoggerFactory);
        }
    }
}
